<template>
	<view style="width: 100%;height: 100vh;background-color: #fff;">
		<view style="height:8%;"></view>
		<view class="logo" style="display: flex;justify-content: center;">
			<view class="cuIcon-friendadd text-theme" style="font-size: 50px;"></view>
		</view>
		<view style="height:4%;"></view>
		<form class="margin-top">
			<view class="cu-form-group">
				<view class="title text-ld">手机号</view>
				<input placeholder="请输入合伙人的手机号码" v-model="mobile"  name="input"></input>
			</view>
			<view class="cu-form-group">
			</view>
		</form>
		<view class="padding flex flex-direction">
			<button class="cu-btn bg-theme lg" @tap="addPartner">
				<text class="text-xl">提交审核</text>
			</button>
		</view>
	</view>
</template>

<script>
	import * as Partner_API from '@/api/member/RegionalManager.js'
	export default {
		data() {
			return {
				mobile:'',
				active:0,
			};
		},
		methods:{
			addPartner(){
				if(this.mobile===''){
					uni.showToast({title:'请输入手机号',icon:'none'})
					return
				}
				if(!(/^1(3|4|5|6|7|8|9)\d{9}$/.test(this.mobile))){
					uni.showToast({title: '请填写正确手机号码',icon:"none"});
					return
				} 
				let params = {
					mobile: this.mobile,
					uuid: uni.getStorageSync('uuid')
				}
				Partner_API.addBrandartner(params).then(res =>{
					if(res == 'SUCCESS'){
						uni.showToast({
							icon:'success',
							title:'提交成功',
							duration:2000
						})
						setTimeout(() =>{
							const pages = getCurrentPages()
							const prevPage = pages[pages.length-2] // 上一页
							prevPage.active = this.active    
							uni.navigateBack()
						},1000)
					}else{
						uni.showToast({
						  title: res.response.data.message,
						  icon: 'none',
						  duration: 2000,
						  success() {
						  	const pages = getCurrentPages()
						  	const prevPage = pages[pages.length-2] // 上一页
						  	prevPage.active = this.active    
						  }
						});
					}
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
